unit PickColor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ClipBrd, PacocUI;

type
  TclrPick = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  clrPick : TclrPick;

implementation
uses
  ClickIt;
{$R *.dfm}

procedure TclrPick.FormCreate(Sender: TObject);
begin
  Self.ClientHeight:= Screen.Height;
  Self.ClientWidth:= Screen.Width;
  Self.Left:= 0;
  Self.Top:= 0;
end;

procedure TclrPick.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  color: Integer;
begin
  color:= Image1.Canvas.Pixels[Mouse.CursorPos.x, Mouse.CursorPos.y]; //Feel free to change?
  PacocUI.Writeln('Color picked: ' + IntToStr(Color) + ' at (' + IntToStr(Mouse.CursorPos.x - ClickIt.ClientBox.Left) + ', ' + IntToStr(Mouse.CursorPos.y - ClickIt.ClientBox.Top) + ')');
  Clipboard.AsText:= IntToStr(Color);
  Self.Hide;
end;

end.
